<template>
	<view style="padding: 40rpx;">
		<view class="content_realization">
			新密码
			<u-input :password="true" border="none" class="realization_input" placeholder="请输入密码" v-model="user.password"></u-input>
			确认密码
			<u-input :password="true" border="none" class="realization_input" placeholder="请再次输入密码" v-model="password_1"></u-input>
		</view>
		<button @click="tologin" type="primary">确定</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				password_1:'',
				user:{},
				a:0
			}
		},
		onLoad:function(e){
			console.log(e);
			this.user.phone=e.phone
			this.a=Number(e.a)
			this.user.id=e.id
		},
		methods: {
			tologin(){
				console.log(this.user);
				if(this.user.password.length==0||this.password_1.length==0){
					uni.$u.toast('密码不能为空')
				}else if(this.user.password!=this.password_1){
					uni.$u.toast('两次密码不一致')
				}else{
					// 调用修改密码接口
					if(this.a==0){
						this.$api.iUserUpdateIntegral(this.user).then(res=>{
							if(res.code==200){
								uni.$u.toast(res.msg)
								uni.navigateTo({
									url:'./userLogin'
								})
							}else{
								uni.$u.toast(res.msg)
							}
						})
					}else{
						this.$api.eUserUpdateIntegral(this.user).then(res=>{
							if(res.code==200){
								uni.$u.toast(res.msg)
								uni.navigateTo({
									url:'./userLogin'
								})
							}else{
								uni.$u.toast(res.msg)
							}
						})
					}
					// 修改成功
					uni.$u.toast('密码已更新，请重新登录')
					uni.navigateTo({
						url:"./userLogin"
					})
				}
			}
		}
	}
</script>

<style>

	.realization_input {
		background-color: #f2f7fb;
		height: 80rpx;
	}

	.content_realization {
		line-height: 80rpx;
		margin-bottom: 40rpx;
	}
</style>
